package com.rxjava.rxjava;

import java.util.HashMap;
import java.util.Map;

import com.google.gson.Gson;

import rx.subjects.BehaviorSubject;

public class UserCache {
	private static BehaviorSubject<User> bs = null;
	static{
		bs =getInstance();
	}
	public static BehaviorSubject<User> getInstance(){
		if(bs==null){
			return BehaviorSubject.create();
		}
		return bs;
	}
	
	public static void next(User user){
		bs.onNext(user);
	}
	
	public static void show(){
		bs.subscribe(s -> System.out.println(new Gson().toJson(s)));
	}

}
